<?php /* Smarty version 2.6.27, created on 2019-11-05 01:58:40
         compiled from menu/items.tpl */ ?>
<?php require_once(SMARTY_CORE_DIR . 'core.load_plugins.php');
smarty_core_load_plugins(array('plugins' => array(array('modifier', 't', 'menu/items.tpl', 25, false),)), $this); ?>
<style type="text/css">
	.sortable-list-sub-<?php echo $this->_tpl_vars['type']; ?>
{margin:5px 12px 5px 0;}
	.sortable-list-sub-<?php echo $this->_tpl_vars['type']; ?>
 td{width:17%;}
	h3 a{font-size:12px;font-weight:normal;}
	a.tabledrag-handle{
		background: url("style/images/draggable.png") no-repeat scroll 6px 7px transparent;
		height: 13px;
		margin: -0.4em 0.5em;
		padding: 0.42em 0.5em;
		width: 13px;
		display:block;
		cursor:move;
	}
	a.tabledrag-handle:hover {background-position:  6px -13px;}
	ul.sortable-list-root-tree h3,ul.sortable-list-root-leaf h3{ height:24px; line-height:24px; border-bottom:solid 1px #BECBD6;}
	.oper-parent span.oper{margin-left:40px; display:none;}
	.oper-parent:hover span.oper{ display:inline;}
</style>

<ul class="sortable-list-root-<?php echo $this->_tpl_vars['type']; ?>
">
	<?php $_from = $this->_tpl_vars['menuTree']; if (!is_array($_from) && !is_object($_from)) { settype($_from, 'array'); }if (count($_from)):
    foreach ($_from as $this->_tpl_vars['menu']):
?>
	<li id="<?php echo $this->_tpl_vars['menu']['mid']; ?>
">
		<div id="menu_line_<?php echo $this->_tpl_vars['menu']['mid']; ?>
" class="oper-parent">
			<h3>
				<em class="menu-icon l"><img src="<?php echo $this->_tpl_vars['menu']['icon']; ?>
" /></em><?php echo ((is_array($_tmp=$this->_tpl_vars['menu']['name'])) ? $this->_run_mod_handler('t', true, $_tmp) : t($_tmp)); ?>

					<span class="oper">
						<a href="javascript:void(0)" onclick="menu_edit(<?php echo $this->_tpl_vars['menu']['mid']; ?>
)">[<?php echo ((is_array($_tmp='编辑')) ? $this->_run_mod_handler('t', true, $_tmp) : t($_tmp)); ?>
]</a>&nbsp;&nbsp;
						<a href="javascript:void(0)" onclick="menu_delete(<?php echo $this->_tpl_vars['menu']['mid']; ?>
)">[<?php echo ((is_array($_tmp='删除')) ? $this->_run_mod_handler('t', true, $_tmp) : t($_tmp)); ?>
]</a>
					</span>
			</h3>

			<ul class="sortable-list-sub-<?php echo $this->_tpl_vars['type']; ?>
">
				<?php $_from = $this->_tpl_vars['menu']['children']; if (!is_array($_from) && !is_object($_from)) { settype($_from, 'array'); }if (count($_from)):
    foreach ($_from as $this->_tpl_vars['menu_sub']):
?>
				<li id="<?php echo $this->_tpl_vars['menu_sub']['mid']; ?>
">
					<table class="itable itable-color" id="menu_line_<?php echo $this->_tpl_vars['menu_sub']['mid']; ?>
">
						<tr>
							<td style="width:2%;"><a class="tabledrag-handle" href="#" title="<?php echo ((is_array($_tmp='拖放重新排序')) ? $this->_run_mod_handler('t', true, $_tmp) : t($_tmp)); ?>
">&nbsp;</a></td>
							<td><?php echo $this->_tpl_vars['menu_sub']['mid']; ?>
</td>
							<td class="edit" id="<?php echo $this->_tpl_vars['menu_sub']['mid']; ?>
" field="name"><?php echo ((is_array($_tmp=$this->_tpl_vars['menu_sub']['name'])) ? $this->_run_mod_handler('t', true, $_tmp) : t($_tmp)); ?>
</td>
							<td style="width:35%;" class="edit" id="<?php echo $this->_tpl_vars['menu_sub']['mid']; ?>
" field="url"><?php echo $this->_tpl_vars['menu_sub']['url']; ?>
</td>
							<td id="<?php echo $this->_tpl_vars['menu_sub']['mid']; ?>
">
								<a href="javascript:void(0)" class="change_status" status="<?php echo $this->_tpl_vars['menu_sub']['status']; ?>
" title="<?php echo ((is_array($_tmp='改变菜单状态')) ? $this->_run_mod_handler('t', true, $_tmp) : t($_tmp)); ?>
">
									<?php if ($this->_tpl_vars['menu_sub']['status'] == @MENU_STATUS_SHOW): ?>
									<?php echo ((is_array($_tmp='显示')) ? $this->_run_mod_handler('t', true, $_tmp) : t($_tmp)); ?>

									<?php else: ?>
									<font color="red"><?php echo ((is_array($_tmp='隐藏')) ? $this->_run_mod_handler('t', true, $_tmp) : t($_tmp)); ?>
</font>
									<?php endif; ?>
								</a>
							</td>
							<td><a href="javascript:void(0)" onclick="menu_delete(<?php echo $this->_tpl_vars['menu_sub']['mid']; ?>
)"><?php echo ((is_array($_tmp='点击删除')) ? $this->_run_mod_handler('t', true, $_tmp) : t($_tmp)); ?>
</a></td>
						</tr>
					</table>
				</li>
				<?php endforeach; endif; unset($_from); ?>
			</ul>
		</div>
	</li>
	<?php endforeach; endif; unset($_from); ?>
<ul>
<br/>
<input type="button" class="gbutton" id="save_menus_<?php echo $this->_tpl_vars['type']; ?>
" value="<?php echo ((is_array($_tmp='保存')) ? $this->_run_mod_handler('t', true, $_tmp) : t($_tmp)); ?>
"/>


<script type="text/javascript">

	$('.sortable-list-root-<?php echo $this->_tpl_vars['type']; ?>
').sortable();
	$('.sortable-list-sub-<?php echo $this->_tpl_vars['type']; ?>
').sortable({
		connectWith: ".sortable-list-sub-<?php echo $this->_tpl_vars['type']; ?>
"
	}).enableSelection();

	//删除菜单
	function menu_delete(mid){
		$.dialog.confirm('<?php echo ((is_array($_tmp='确定删除菜单?')) ? $this->_run_mod_handler('t', true, $_tmp) : t($_tmp)); ?>
', function(){
			$.ajax({
				type: "POST",
				url: "admin.php?ctrl=menu&act=submit&t=del",
				data: 'mid='+mid,
				timeout: 20000,
				error: function(){$.dialog.alert('<?php echo ((is_array($_tmp='超时')) ? $this->_run_mod_handler('t', true, $_tmp) : t($_tmp)); ?>
');},
				success: function(result){
					if(result == 'success'){
						$.dialog.tips('<?php echo ((is_array($_tmp='删除成功')) ? $this->_run_mod_handler('t', true, $_tmp) : t($_tmp)); ?>
');
						$('#menu_line_'+mid).remove();
					}else{
						$.dialog.alert('<?php echo ((is_array($_tmp='删除失败')) ? $this->_run_mod_handler('t', true, $_tmp) : t($_tmp)); ?>
');
					}

				}
			});
		}, function(){
			$.dialog.tips('<?php echo ((is_array($_tmp='取消操作')) ? $this->_run_mod_handler('t', true, $_tmp) : t($_tmp)); ?>
');
		});
	}

	//保存菜单排序
	$('#save_menus_<?php echo $this->_tpl_vars['type']; ?>
').click(function(){
		var menu_root_ids;
		var menu_sub_ids = new Array();
		$('.sortable-list-root-<?php echo $this->_tpl_vars['type']; ?>
').each(function(){
			menu_root_ids = $(this).sortable('toArray')
		});
		$('.sortable-list-sub-<?php echo $this->_tpl_vars['type']; ?>
').each(function(){
			menu_sub_ids.push($(this).sortable('toArray'));
		});
		$.ajax({
			type: "POST",
			url: "admin.php?ctrl=menu&act=submit&t=save_weight&type=<?php echo $this->_tpl_vars['type']; ?>
",
			data: 'menu_root_ids='+menu_root_ids+'&menu_sub_ids='+menu_sub_ids.join('|'),
			timeout: 20000,
			error: function(){alert('error')},
			success: function(result){
				if(result == 1) alert('<?php echo ((is_array($_tmp='修改成功')) ? $this->_run_mod_handler('t', true, $_tmp) : t($_tmp)); ?>
');
			}
		});
	});

	$('.edit').editable("admin.php?ctrl=menu&act=submit&t=save_field", {
		indicator : "<img src='style/images/indicator.gif'>",
		height    : "15px",
		submit    : "<?php echo ((is_array($_tmp='修改')) ? $this->_run_mod_handler('t', true, $_tmp) : t($_tmp)); ?>
",
		cancel    : "<?php echo ((is_array($_tmp='取消')) ? $this->_run_mod_handler('t', true, $_tmp) : t($_tmp)); ?>
",
		tooltip   : "<?php echo ((is_array($_tmp='点击修改')) ? $this->_run_mod_handler('t', true, $_tmp) : t($_tmp)); ?>
...",
		style  : "inherit"
	});

	//改变菜单状态：显示或隐藏
	$('.change_status').click(function(){
		var $this = $(this);
		var id = $(this).parent().attr('id');
		var value = $(this).attr('status')==1? 2: 1;
		$.ajax({
			type: "POST",
			url: "admin.php?ctrl=menu&act=submit&t=save_field",
			data: 'id='+id+'&field=status'+'&value='+value,
			timeout: 20000,
			error: function(){alert('error');},
			success: function(result){
				$this.attr('status', result);
				if(result == '1'){
					$this.html('<?php echo ((is_array($_tmp='显示')) ? $this->_run_mod_handler('t', true, $_tmp) : t($_tmp)); ?>
');
				}
				if(result == '2'){
					$this.html('<font color="red"><?php echo ((is_array($_tmp='隐藏')) ? $this->_run_mod_handler('t', true, $_tmp) : t($_tmp)); ?>
</font>');
				}
			}
		});
	});

	//点击编辑时跳换到添加菜单
	function menu_edit(mid){
		$menu_tabs_<?php echo $this->_tpl_vars['type']; ?>
.tabs( "url" , 1 , "admin.php?ctrl=menu&act=edit&mid="+mid );
		$menu_tabs_<?php echo $this->_tpl_vars['type']; ?>
.tabs( "select" , 1 );
	}
</script>